package com.mall507.fivepeaks.widget.xdialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import com.hzh.frame.util.AndroidUtil;
import com.hzh.frame.widget.xdialog.XDialogFragment;
import com.mall507.fivepeaks.R;
import com.mall507.fivepeaks.util.Util;

/**
 * 用户签到满7天奖励提示框
 * */
public class XMineChooseDialog {

	private Dialog alertDialog;
	private Window mWindow;
	private Activity mActivity;
	private Context mContext;
	private TextView close;
	
	/**
	 * @param context
	 * @param callback 选择结果回调
	 * */
	public void show(final Context context,String msg1,final XUserMainSignRewardDialogCallBack callback) {
		//防止网络延迟情况下多次点击弹出多个窗口
		dismiss();
		alertDialog = new Dialog(context, R.style.chooseDialog);
		LayoutInflater in = LayoutInflater.from(context);
		View viewDialog = in.inflate(R.layout.view_xdialog_editsex, null);
		
		TextView msg = viewDialog.findViewById(R.id.choosesex);
		TextView confirm= viewDialog.findViewById(R.id.confirm);
		TextView cancel= viewDialog.findViewById(R.id.cancel);
		TextView close = viewDialog.findViewById(R.id.close);
        final CheckBox checkone = viewDialog.findViewById(R.id.checkone);
        final CheckBox checktwo = viewDialog.findViewById(R.id.checktwo);
        checkone.setChecked(true);
		msg.setText(msg1);
		close.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                callback.cancel();
            }
        });
		confirm.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				dismiss();
				callback.confirm();
			}
		});
		cancel.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				dismiss();
				callback.cancel();
			}
		});
        int width = AndroidUtil.getWindowWith();
        int height = AndroidUtil.getWindowHeight();
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(width, height);
		alertDialog.setContentView(viewDialog,layoutParams);
		// 点击对话框外部取消对话框显示
		alertDialog.setCanceledOnTouchOutside(true);
		alertDialog.show();
	}
	
	/**
	 * 关闭当前Dialog
	 * */
	public void dismiss(){
		if(alertDialog!=null && alertDialog.isShowing()){
			alertDialog.dismiss();
		}
	}

    


    /**
	 * 选择结果回调
	 * */
	public interface XUserMainSignRewardDialogCallBack{
		  /**
		   * 确定
		   */
		  void confirm();
		  
		  /**
		   * 取消
		   */
		  void cancel();
	}

    public Window getWindow() {
        return mWindow;
    }
}
